package org.minhnhut.PhimSo;

import java.util.ArrayList;

import com.example.demolistview.R;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.view.Menu;
import android.widget.ListView;

public class MainActivity extends ListActivity {

    private ArrayList<Film> films;
	ListView listView;
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        TypedArray arrImg = getResources().obtainTypedArray(R.array.img);
        TypedArray arrName = getResources().obtainTypedArray(R.array.fname);
        TypedArray arrYear = getResources().obtainTypedArray(R.array.fyear);
        TypedArray arrPrice = getResources().obtainTypedArray(R.array.fprice);
        
        listView = (ListView) findViewById(R.id.listView1);
        
		films = new ArrayList<Film>();
        for (int i = 0; i < arrImg.length(); i++) {
        	Drawable drawable = arrImg.getDrawable(i);
        	String mName  = arrName.getString(i);
        	String mYear = arrYear.getString(i);
        	String mPrice = arrPrice.getString(i);
			
        	Film film = new Film(drawable, mName, mYear, mPrice);
        	films.add(film);
		}
        MyAdapter adapter = new MyAdapter(getApplicationContext(), R.layout.img_layout, films);
        setListAdapter(adapter);
  }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}
